cssjshtml vue.js 时间刷新

葫芦的运维日志

浏览量 5801 2018/10/11 23:59

显示当前时间:

源码:


<!--
# @Time    : 2018/10/10 上午12:39
# @Author  : BrownWang
# @Email   : 277215243@qq.com
# @File    : vuedemo.html
# @Software: PyCharm -->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="app">
{{date}}
</div>
<script src="/static/js/vue.min.js"></script>
<script>
    var app=new Vue({
        el:'#app',
        data:{
           date:new Date()
        },
        mounted:function(){
           var _this=this;
           this.timer=setInterval(function(){
           _this.date=new Date();
           },1000)},
        beforDestroy:function(){
          if(this.timer){
           clearInterval(this.timer);
        }
       }
    })
</script>
</body>
</html>

 

📝 版权声明

本文作者:王梓 | 原文链接:https://www.bthlt.com/note/119-vue.js 时间刷新

出处:葫芦的运维日志 | 转载请注明出处并保留原文链接

打赏

留言板

留言提交后需管理员审核通过才会显示

© 冰糖葫芦甜(bthlt.com) 2025 王梓打赏联系方式陕ICP备17005322号-1